<?php
  include('header.php');
  $id = $_GET['id'];
  $sql = "select * from apply where id = $id";
  $result = mysqli_query($conn, $sql);
  if($result) {
    $row = mysqli_fetch_assoc($result);
    $book_id = $row['book_id'];
  }
  $sql_book = "select * from book where id=$book_id";
  $result_book = mysqli_query($conn, $sql_book);
  if($result_book) {
    $row_book = mysqli_fetch_assoc($result_book);
  }
?>
    <div class="layui-body" style="padding: 15px;">
    <!-- 个人中心 - 借阅申请详情 -->
      <!-- 内容主体区域 -->
      <div>个人中心</div>
      <div class="layui-tab layui-tab-brief">
        <ul class="layui-tab-title">
          <li><a class="layui-this">借阅申请详情</a></li>
        </ul>
      </div>

      <div class="layui-tab-content">
        <div class="layui-tab-item layui-show">
          <div class="layui-row">
            <div class="layui-col-md8">
              <form class="layui-form" method="post" action="me_apply_update.php">
                <input type="hidden" name="id" value="<?php echo $id; ?>" />
                <div class="layui-form-item">
                  <label class="layui-form-label">图书名称</label>
                  <div class="layui-input-block">
                    <input type="text" class="layui-input" value="<?php echo $row_book['book_name']; ?>" disabled="disabled" />
                  </div>
                </div>

                <div class="layui-form-item">
                  <label class="layui-form-label">图书分类</label>
                  <div class="layui-input-block">
                    <select name="book_category" lay-verify="required" disabled="disabled">
                        <option value="">请选择类型</option>
                        <?php
                          $sql = "select * from category order by id";
                          $result = mysqli_query($conn, $sql);
                          if($result) {
                            while($rows = mysqli_fetch_assoc($result)) {
                              if($rows['category_name'] == $row_book['book_category']) {
                                echo "<option selected='selected' value=".$rows['category_name'].">".$rows['category_name']."</option>";
                              } else {
                                echo "<option value=".$rows['category_name'].">".$rows['category_name']."</option>";
                              }
                            }
                          }
                        ?>
                      </select>
                  </div>
                </div>

                <div class="layui-form-item">
                  <label class="layui-form-label">图书位置</label>
                  <div class="layui-input-block">
                    <select name="book_position" lay-verify="required" disabled="disabled">
                        <option value="">请选择类型</option>
                        <?php
                          $sql = "select * from position order by id";
                          $result = mysqli_query($conn, $sql);
                          if($result) {
                            while($rows = mysqli_fetch_assoc($result)) {
                              if($rows['position_name'] == $row_book['book_position']) {
                                echo "<option selected='selected' value=".$rows['position_name'].">".$rows['position_name']."</option>";
                              } else {
                                echo "<option value=".$rows['position_name'].">".$rows['position_name']."</option>";
                              }
                            }
                          }
                        ?>
                      </select>
                  </div>
                </div>

                <div class="layui-form-item">
                  <label class="layui-form-label">图书数量</label>
                  <div class="layui-input-block">
                    <input type="text" name="book_count" class="layui-input" value="<?php echo $row_book['book_count'] ?>" disabled="disabled" />
                  </div>
                </div>

                <div class="layui-form-item">
                  <label class="layui-form-label">借阅数量</label>
                  <div class="layui-input-block">
                    <input type="text" name="apply_num" class="layui-input" value="<?php echo $row['apply_num'] ?>" />
                  </div>
                </div>

                <div class="layui-form-item">
                  <div class="layui-input-block">
                    <input type="submit" class="layui-btn layui-btn-normal" value="提交" />
                  </div>
                </div>
              </form>
            </div>
          </div>
        </div>
      </div>

    </div>
<?php
  include('footer.php');
?>